package net.novasharper.icarus.graphics;

import java.util.HashMap;

import org.lwjgl.opengl.Display;
import org.newdawn.slick.opengl.Texture;

public class RenderEngine {
	private HashMap<String, Texture> textureHolder;
	private HashMap<String, SpriteInfo> spriteInfoHolder;
	
	private class SpriteInfo {
		public int width;
		public int height;
		public SpriteInfo(int width, int height) {
			this.width = width;
			this.height = height;
		}
	}
	
	public RenderEngine() {
		textureHolder = new HashMap<String, Texture>();
		spriteInfoHolder = new HashMap<String, SpriteInfo>();
	}
	
	public void registerTexture(String id, Texture tex) {
		registerSpriteSheet(id, tex, 1, 1);
	}
	
	public void registerSpriteSheet(String id, Texture tex, int width, int height) {
		if(!textureHolder.containsKey(id)) {
			textureHolder.put(id, tex);
			spriteInfoHolder.put(id, new SpriteInfo(width, height));
		}
	}
	
	public Texture getTexture(String id) {
		if(!textureHolder.containsKey(id)) throw new InvalidIDException("No Such Texture ID!");
		return textureHolder.get(id);
	}
	
	public int[] getSize(String id) {
		if(!textureHolder.containsKey(id)) throw new InvalidIDException("No Such Texture ID!");
		return new int[] { spriteInfoHolder.get(id).width, spriteInfoHolder.get(id).height };
	}

	public void update() {
		Display.update();
	}
	
	public void drawSprite(String name, Location loc) {
	}
}
